<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .active {
      color: red;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- <h2 v-bind:class="{key1}:value1,key2:value2}">{{message}}</h2>
    <h2 v-bind:class="{类名1:true,类名2:boolean}">{{message}}</h2> -->
    <h2 class="title" v-bind:class="{active:isactive,line:isline}">{{message}}</h2>
    <h2 class="title" v-bind:class="getclasses()">{{message}}</h2>
    <!-- 和普通类同时存在，不冲突 注：如果isactive和isline都为true，那么会有title/active/line三个类 -->
    <button v-on:click="btnclick">按钮</button>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    //v-bind绑定class
    const app = new Vue({
      el: '#app',
      data: {
        message: '你好啊',
        isactive: true,
        isline: true
      },
      methods: {
        btnclick: function () {
          this.isactive = !this.isactive
        },
        getclasses: function () {
          return { active: this.isactive, line: this.isline }
        }
      }
    })
  </script>
</body>

</html>